package com.eckey.lab.feign;

import com.eckey.lab.entity.Storage;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Marinc
 * @CreateTime: 2023-09-24  15:52
 * @Description: TODO
 * @Version: 1.0
 */
@Component
@FeignClient(name = "storage-service", fallbackFactory = StorageFallbackFactory.class)
public interface StorageFeign {

    @GetMapping("/storage/{id}")
    ResponseEntity<Storage> queryById(@PathVariable("id") Integer id);

    /**
     * 新增数据
     *
     * @param storage 实体
     * @return 新增结果
     */
    @PostMapping("/storage")
    ResponseEntity<Storage> add(Storage storage);

    /**
     * 编辑数据
     *
     * @param storage 实体
     * @return 编辑结果
     */
    @PutMapping("/storage")
    ResponseEntity<Storage> edit(Storage storage);

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/storage")
    ResponseEntity<Boolean> deleteById(Integer id);

    @PostMapping("/storage/deduct")
    String deduct(@RequestParam("name") String name, @RequestParam("totalPrice") Integer totalPrice);

}
